#!/bin/bash

set -euo pipefail

echo "curl http://demo:demo@127.0.0.1:8083/streams"
curl http://demo:demo@127.0.0.1:8083/streams
sleep 1
echo "http://demo:demo@127.0.0.1:8083/stream/testing/add"
curl --header "Content-Type: application/json" \
  --request POST \
  --data '{
              "name": "test video",
              "channels": {
                  "0": {
                      "name": "ch1",
                      "url": "rtsp://admin:admin123@10.128.18.224/mpeg4",
                      "on_demand": false,
                      "debug": false,
                      "status": 0
                  },
                  "1": {
                      "name": "ch2",
                      "url": "rtsp://admin:admin123@10.128.18.224:999/mpeg4cif",
                      "on_demand": true,
                      "debug": false,
                      "status": 0
                  }
              }
          }' \
  http://demo:demo@127.0.0.1:8083/stream/testing/add
sleep 1
echo "http://demo:demo@127.0.0.1:8083/stream/testing/edit"
curl --header "Content-Type: application/json" \
    --request POST \
    --data '{
              "name": "test video",
              "channels": {
                  "0": {
                      "name": "ch1",
                      "url": "rtsp://admin:admin123@10.128.18.224/mpeg4",
                      "on_demand": true,
                      "debug": false,
                      "status": 0
                  },
                  "1": {
                      "name": "ch2",
                      "url": "rtsp://admin:admin123@10.128.18.224/mpeg4",
                      "on_demand": false,
                      "debug": false,
                      "status": 0
                  }
              }
          }' \
    http://demo:demo@127.0.0.1:8083/stream/testing/edit
sleep 1
echo "http://demo:demo@127.0.0.1:8083/stream/testing/channel/4/add"
curl --header "Content-Type: application/json" \
  --request POST \
  --data '{
                      "name": "ch4",
                      "url": "rtsp://admin:admin@YOU_CAMERA_IP/uri",
                      "on_demand": false,
                      "debug": false,
                      "status": 0
            }' \
  http://demo:demo@127.0.0.1:8083/stream/testing/channel/4/add
sleep 1
echo "http://demo:demo@127.0.0.1:8083/stream/testing/channel/4/edit"
curl --header "Content-Type: application/json" \
  --request POST \
  --data '{
                      "name": "ch4",
                      "url": "rtsp://admin:admin@YOU_CAMERA_IP/uri",
                      "on_demand": true,
                      "debug": false,
                      "status": 0
            }' \
  http://demo:demo@127.0.0.1:8083/stream/testing/channel/4/edit
sleep 1
echo "http://demo:demo@127.0.0.1:8083/stream/testing/channel/4/info"
curl http://demo:demo@127.0.0.1:8083/stream/testing/channel/4/info
sleep 1
echo "http://demo:demo@127.0.0.1:8083/stream/testing/channel/4/codec"
curl http://demo:demo@127.0.0.1:8083/stream/testing/channel/4/codec
sleep 1
echo "http://demo:demo@127.0.0.1:8083/stream/testing/channel/4/delete"
curl http://demo:demo@127.0.0.1:8083/stream/testing/channel/4/delete
sleep 1
echo "http://demo:demo@127.0.0.1:8083/stream/testing/reload"
curl http://demo:demo@127.0.0.1:8083/stream/testing/reload
sleep 1
echo "http://demo:demo@127.0.0.1:8083/stream/testing/info"
echo "/stream/testing/info"
curl http://demo:demo@127.0.0.1:8083/stream/testing/info
sleep 1
echo "http://demo:demo@127.0.0.1:8083/stream/testing/delete"
curl http://demo:demo@127.0.0.1:8083/stream/testing/delete
sleep 1
echo "http://demo:demo@127.0.0.1:8083/pages/multiview/full"
curl --header "Content-Type: application/json" \
  --request POST \
  --data '{
            "grid":6,
            "player":{

              "1": {
                "uuid": "d43e9364-e2e3-4b41-9f78-b90de1991211",
                "channel": 1,
                "playerType": "mse"
              },
              "2": {
                "uuid": "d43e9364-e2e3-4b41-9f78-b90de1991211",
                "channel": 0,
                "playerType": "mse"
              },
              "3": {
                "uuid": "d43e9364-e2e3-4b41-9f78-b90de1991211",
                "channel": 1,
                "playerType": "hls"
              },
              "4": {
                "uuid": "d43e9364-e2e3-4b41-9f78-b90de1991211",
                "channel": 0,
                "playerType": "mse"
              },
              "6": {
                "uuid": "d43e9364-e2e3-4b41-9f78-b90de1991211",
                "channel": 1,
                "playerType": "mse"
              }
            }
          }' \
  http://demo:demo@127.0.0.1:8083/pages/multiview/full
